package com.mdx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mdx.bean.DiseaseBean;
import com.mdx.bean.ExpertBean;
import com.mdx.dao.ExpertDao;
import com.mdx.service.IExpertService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ExpertServiceImpl extends ServiceImpl<ExpertDao, ExpertBean> implements IExpertService {

    @Override
    public IPage<ExpertBean> findByItem(int pageNO, int pageSize, String expertName, String specialty, String jobUnit) {
        IPage<ExpertBean> page = new Page<>(pageNO,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if (expertName != null && !expertName.equals("")){
            wrapper.like("f_expertName",expertName);
        }
        if (specialty != null && !specialty.equals("")){
            wrapper.like("f_specialty",specialty);
        }
        if (jobUnit != null && !jobUnit.equals("")){
            wrapper.like("f_jobUnit",jobUnit);
        }
        IPage<ExpertBean> iPage = this.page(page,wrapper);
        return iPage;
    }

    @Override
    public void updateById(int expertId, String expertTel, String office, String jobUnit, String email) {
        ExpertBean expertBean = this.getById(expertId);
        expertBean.setExpertTel(expertTel);
        expertBean.setJobUnit(jobUnit);
        expertBean.setEmail(email);
        expertBean.setOffice(office);
        this.updateById(expertBean);
    }


}
